<template>
  <el-dialog title="添加版本审批" :close-on-click-modal="false" :visible.sync="messageShow" class="view">
    <el-form
      :model="dataForm"
      ref="dataForm"
      @keyup.enter.native="dataFormSubmit()"
      label-width="150px"
    >
      <el-form-item label="版本号" prop="version">
        <el-input v-model="dataForm.version" placeholder="版本号"></el-input>
      </el-form-item>
      <el-form-item label="是否审核通过" prop="isAudit">
        <el-radio v-model="dataForm.isAudit" :label="0">通过</el-radio>
        <el-radio v-model="dataForm.isAudit" :label="1">未通过</el-radio>
      </el-form-item>
      <el-form-item label="是否过期" prop="isExpire">
        <el-radio v-model="dataForm.isExpire" :label="1">未过期</el-radio>
        <el-radio v-model="dataForm.isExpire" :label="0">过期</el-radio>
      </el-form-item>
      <el-form-item label="操作系统" prop="type">
        <el-radio v-model="dataForm.type" :label="1">ios</el-radio>
        <el-radio v-model="dataForm.type" :label="2">安卓</el-radio>
      </el-form-item>
    </el-form>
    <span slot="footer" class="dialog-footer">
      <el-button type="primary" @click="dataFormSubmit">确定</el-button>
      <el-button @click="messageShow = false">取消</el-button>
    </span>
  </el-dialog>
</template>

<script>
  export default {
    data() {
      return {
        dataForm: {},
        steward: [{}],
        messageShow: false
      }
    },
    methods: {
      initData (id) {
        this.messageShow = true
        if (id) {
          this.$http({
            url: this.$http.adornUrl(`/common/appversion/info/${id}`),
            method: "get",
          }).then(({ data }) => {
            this.dataForm = data.appVersion
          })
        } else {
          this.dataForm = {}
        }
      },
      dataFormSubmit () {
        const data = this.dataForm
        if(data.id){
          this.$http({
            url: this.$http.adornUrl(`/common/appversion/update`),
            method: "post",
            data
          }).then(({ data }) => {
            console.log(data)
            this.messageShow = false
            this.$emit('refresh')
          })
        } else {
          this.$http({
            url: this.$http.adornUrl(`/common/appversion/save`),
            method: "put",
            data
          }).then(({ data }) => {
            console.log(data)
            this.messageShow = false
            this.$emit('refresh')
          })
        }
      }
    }
  };
</script>
<style scoped>
  .otherContent{
    padding: 0 60px;
  }
  .el-row{
    display: flex;
    align-items: center;
    height: 45px;
    font-size: 16px;
  }
</style>
